<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">  
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<title>专利协同服务平台</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/H-ui.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/regist.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.validate-1.13.1.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/additional-methods.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery_vlid_set.js"></script>
	<script type="text/javascript">
	  var PHONECODE=0;
	  $(document).ready(function(){
		  $("#getPhoneCode").click(function(){
	        	  var phonerNumber=$("#phoneNumber").val();
	        	  var errormsg=$("#errormsg"); 
	        	  if(phonerNumber!= null&& phonerNumber !=""){
	        		  $.ajax({  
		                  url:"${pageContext.request.contextPath}/researcher/sendRegistCode.html", 
		                  type:"post",  
		                  data:{  
		                      "phoneNumber":phonerNumber,
		                  },  
		                  dataType:"text",  
		                  success : function(data) {  
		                      if(data=='fail'){  
		                    	  errormsg.html("<font color='red'>该手机号已经注册</font>");
		                      } else {  
		                    	  PHONECODE=data;	//页面暂存验证码
		                    	  time(this);	
		                     } 
		                  }//end success
		              }); //end ajax
	        	  }else{
	        		  errormsg.html("<font color='red'>请输入手机号</font>"); 
	        	  }
	          });//end click 
		  $("#button").click(function(){
				var message = $("#message");
				var code=$("#code").val();
				var codeerrormsg=$("#errormsg"); 
				layer.msg(PHONECODE+":"+code)
				if(PHONECODE==code)	{
					$.ajax({
				   		type: "POST",
				   		url: "${pageContext.request.contextPath}/researcher/regist.html",  
				   		data: $("#registform").serialize(),
				   		dataType:'text',
				   		success:function(data) {
				   			layer.msg("恭喜您注册成功,2s后自动跳转到首页");
				   			setTimeout(function() {     //2s后执行 
				   				window.location="${pageContext.request.contextPath}/redirect/index.html";
				   	         },2000);
				   			
				   		}
				   	}); 
				}else{
					codeerrormsg.html("<font color='red'>验证码输入错误</font>"); 
				}
			});
		  });	//end jquery
	  //按钮倒计时
	  var wait=60;
	  function time(obj){
	 	 if(wait==0) {  
	 		 $("#getPhoneCode").removeAttr("disabled");  
	 		 $("#getPhoneCode").val("获取验证码");  
	         wait = 60;  
	      }else {  
	    	 $("#getPhoneCode").attr("disabled","disabled");  
	    	 $("#getPhoneCode").val(wait+"秒后重试");  
	         wait--;  
	         setTimeout(function() {     //倒计时方法  
	         time(obj);  
	         },1000);   	 //间隔为1s  
	      }  
	  }//end method
	</script>
<style type="text/css">
.logo2{
	margin-left:-40px;
	margin-top: -25px;
}
</style>
</head>
<body>
		
		<div id="contain" class="c_contain">
    	<div id="top" class="c_top" style="background: #015AB8;">
    		<!-- 标题文字 -->
    		<img alt="logo2"
				src="${pageContext.request.contextPath}/images/index_logo2.png"
				class="logo2">
    	</div>
    	<div id="center" class="c_center" >
    		<div  id="id_form" class="panel panel-default">
				<div class="panel-header">>>忘记密码-设置新密码</div>
				<div class="panel-body">
					<form action="#" method="post" class="form form-horizontal responsive" id="registform">
						<div class="row cl">
							<div class="formControls col-xs-8">
								<label class="form-label col-xs-3"></label>
								<input style="background: #EBEBE4; border: none;color: #333333; width:150px; margin-left: 135px;"
								 	class="btn btn-primary" type="button" value="获取验证码" id="getPhoneCode"/>
								<span id="errormsg" style="padding-left: 20px; display: inline;"></span>
							</div>
						</div>
						<div class="row cl">
							<label class="form-label col-xs-3">新密码：</label>
							<div class="formControls col-xs-8">
								<input style="width: 600px;"
								type="password" class="input-text" autocomplete="off" placeholder="请输入密码-长度6-15位" name="password" id="password">
							</div>
						</div>
						<div class="row cl">
							<label class="form-label col-xs-3">确认密码：</label>
							<div class="formControls col-xs-8">
								<input style="width: 600px;"
								type="password" class="input-text" autocomplete="off" placeholder="确认密码" name="password2" id="password2">
							</div>
						</div>
						<div class="row cl">
							<div class="col-xs-8 col-xs-offset-3">
								<input id="button" class="btn btn-primary" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
							</div>
						</div>
					</form>
				</div>
			</div>
    	</div><!-- center结束 -->
    </div>
</body>
</html>